home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / 3D Additions 1.7 / 3D Demo src / C3DDemoApp.cp < prev    next >
Encoding:
Text File  |  1995-01-24  |  4.6 KB  |  170 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    C3DDemoApp.cp
  3. // ===========================================================================
  4.  
  5.  
  6. #pragma once
  7.  
  8. #include "C3DDemoApp.h"
  9. #include "C3DDemoWin.h"
  10.  
  11. #include <LApplication.h>
  12. #include <LGrowZone.h>
  13. #include <LRadioGroup.h>
  14. #include <LWindow.h>
  15. #include <UMemoryMgr.h>
  16. #include <UDrawingState.h>
  17. #include <URegistrar.h>
  18. #include <UPowerTools.h>
  19.  
  20. #include <3DobClasses.h>
  21.  
  22. const ResIDT    WIND_3DDemo    = 200;
  23.  
  24.  
  25. // ===========================================================================
  26. //        • Main Program
  27. // ===========================================================================
  28.  
  29. void main(void)
  30. {
  31.                                     // Set Debugging options
  32. #ifdef Debug_Throw
  33.     gDebugThrow = debugAction_Alert;
  34. #endif
  35.  
  36. #ifdef Debug_Signal
  37.     gDebugSignal = debugAction_Alert;
  38. #endif
  39.  
  40.     InitializeHeap(3);                // Initialize Memory Manager
  41.                                     // Parameter is number of Master Pointer
  42.                                     //   blocks to allocate
  43.     
  44.                                     // Initialize standard Toolbox managers
  45.     UQDGlobals::InitializeToolbox(&qd);
  46.     
  47. #ifdef Debug_Signal                    // Check for missing MBAR, which
  48.     CheckForInitialMBAR();            // probably means that there is no
  49. #endif                                // project resource file
  50.     
  51.     new LGrowZone(20000);            // Install a GrowZone function to catch
  52.                                     //    low memory situations.
  53.                                     //    Parameter is size of reserve memory
  54.                                     //    block to allocated. The first time
  55.                                     //    the GrowZone function is called,
  56.                                     //    there will be at least this much
  57.                                     //    memory left (so you'll have enough
  58.                                     //    memory to alert the user or finish
  59.                                     //    what you are doing).
  60.     
  61.     C3DDemoApp    theApp;            // Create instance of your Application
  62.     theApp.Run();                    //   class and run it
  63. }
  64.  
  65.  
  66. // ===========================================================================
  67. //        • C3DDemoApp Class
  68. // ===========================================================================
  69.  
  70. // ---------------------------------------------------------------------------
  71. //        • C3DDemoApp
  72. // ---------------------------------------------------------------------------
  73. //    Constructor
  74.  
  75. C3DDemoApp::C3DDemoApp()
  76. {
  77.         // Register classes for objects created from 'PPob' resources
  78.         
  79.     URegistrar::RegisterClass(LWindow::class_ID,        LWindow::CreateWindowStream);
  80.     URegistrar::RegisterClass(LRadioGroup::class_ID,    LRadioGroup::CreateRadioGroupStream);
  81.  
  82.     URegistrar::RegisterClass(C3DDemoWin::class_ID,        C3DDemoWin::CreateFromStream);
  83.  
  84.     RegisterAll3DClasses();
  85.     
  86.         // A 3DDemo program has a single main Window that is
  87.         // displayed on start up. The "Visible on Creation" option
  88.         // for the Window (in its PPob resource) should be OFF,
  89.         // so that you can adjust the Window's contents before
  90.         // displaying it.
  91.         
  92.     mDisplayWindow = LWindow::CreateWindow(WIND_3DDemo, this);
  93.     
  94.         // +++ Add code here to configure Panes inside the Window
  95.         
  96.     mDisplayWindow->Show();
  97. }
  98.  
  99.  
  100. // ---------------------------------------------------------------------------
  101. //        • ~C3DDemoApp
  102. // ---------------------------------------------------------------------------
  103. //    Destructor
  104.  
  105. C3DDemoApp::~C3DDemoApp()
  106. {
  107.         // +++ Add code here to cleanup (if necessary) before quitting
  108. }
  109.  
  110.  
  111. // ---------------------------------------------------------------------------
  112. //        • ObeyCommand
  113. // ---------------------------------------------------------------------------
  114. //    Respond to commands
  115.  
  116. Boolean
  117. C3DDemoApp::ObeyCommand(
  118.     CommandT    inCommand,
  119.     void        *ioParam)
  120. {
  121.     Boolean    cmdHandled = true;
  122.     
  123.     switch (inCommand) {
  124.     
  125.         // +++ Add cases here for the commands you handle
  126.         //        Remember to add same cases to FindCommandStatus below
  127.         //        to enable/disable the menu items for the commands
  128.     
  129.         default:
  130.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  131.             break;
  132.     }
  133.     
  134.     return cmdHandled;
  135. }
  136.  
  137.  
  138. // ---------------------------------------------------------------------------
  139. //        • FindCommandStatus
  140. // ---------------------------------------------------------------------------
  141. //    Pass back status of a (menu) command
  142.  
  143. void
  144. C3DDemoApp::FindCommandStatus(
  145.     CommandT    inCommand,
  146.     Boolean        &outEnabled,
  147.     Boolean        &outUsesMark,
  148.     Char16        &outMark,
  149.     Str255        outName)
  150. {
  151.     outUsesMark = false;
  152.     
  153.     switch (inCommand) {
  154.     
  155.         // +++ Add cases here for the commands you handle.
  156.         //
  157.         //        Set outEnabled to TRUE for commands that can be executed at
  158.         //        this time.
  159.         //
  160.         //        If the associated menu items can have check marks, set
  161.         //        outUsesMark and outMark accordingly.
  162.         //
  163.         //        Set outName to change the name of the menu item
  164.     
  165.         default:
  166.             LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  167.                                 outMark, outName);
  168.             break;
  169.     }
  170. }